package com.modai.springcloud.entities;


import com.modai.springcloud.service.HystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author ：modai
 * @date ：Created in 2020-12-7 18:45
 * @description：
 */
@RestController
@Slf4j
public class PaymentHystrixController {

    @Resource
    private HystrixService hystrixService;

    @GetMapping("/payment/hystrix/ok/{id}")
    public String responseOk(@PathVariable("id") int id) {
        String res = hystrixService.responseOk(id);
        log.info("+++{}", res);
        return res;
    }

    @GetMapping("/payment/hystrix/timeout/{id}")
    public String responseTimeout(@PathVariable("id") int id) {
        String res = hystrixService.responseTimeout(id);
        log.info("+++{}", res);
        return res;
    }

    @GetMapping("/payment/hystrix/check/{num}")
    public String checkNumber(@PathVariable("num") int num) {
        String res = hystrixService.getNoneNegativeNumber(num);
        log.info("+++{}", res);
        return res;
    }

}
